<!DOCTYPE HTML>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />

    <link href="/static/v5/static/h-ui/css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="/static/v5/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="/static/v5/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link href="/static/v5/static/h-ui.admin/css/H-ui.login.css" rel="stylesheet" type="text/css" />
    <link href="/static/v5/static/h-ui.admin/css/style.css" rel="stylesheet" type="text/css" />
    <link href="/static/v5/lib/Hui-iconfont/1.0.8/iconfont.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="/static/v5/css/kkpager_blue.css" />
    <title></title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 文章管理 <span class="c-gray en">&gt;</span> 文章管理  <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">

    <div class="text-c" style="float:left ;margin-bottom: 20px">
        <th:block th:if="${retInfo.obj.arti_name == '100000000'}">
            <input type="text" name="" id="arti_name" placeholder="文章名称" style="width:250px" class="input-text">
        </th:block>
        <th:block th:if="${retInfo.obj.arti_name != '100000000'}">
            <input type="text" name="" id="arti_name" th:value="${retInfo.obj.arti_name}" placeholder="文章名称" style="width:250px" class="input-text">
        </th:block>
        <span class="select-box inline">
				<select name="" class="select" id="cate_id">
					<option value="0" th:selected="${0 == retInfo.obj.cate_id}">全部分类</option>
					 <th:block  th:each="bean: ${articleCates}">
                        <option th:value="${bean.cate_id}" th:text="${bean.cate_name}" th:selected="${bean.cate_id == retInfo.obj.cate_id}"></option>
					  </th:block>
				</select>
				</span>
        <button name="" id="" class="btn btn-success" type="button" onclick="search()"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
    </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th width="50">id</th>
                <th width="100">标题</th>
                <th width="100">类别</th>
                <th width="50">排序</th>
                <th width="50">评论数</th>
                <th width="50">评论人数</th>
                <th width="50">发布人</th>
                <th width="50">是否推荐</th>
                <th width="50">是否可评论</th>
                <th width="50">添加人</th>
                <th width="130">添加时间</th>
                <th width="50">最后更新人</th>
                <th width="130">最后更新时间</th>
                <th width="100">操作</th>
            </tr>
            </thead>

                <tbody >
                <th:block  th:each="bean: ${retInfo.obj.article}">
                    <tr class="text-c" id="table">
                        <td th:text="${bean.id}"></td>
                        <td th:text="${bean.arti_name}"></td>
                        <td th:text="${bean.cate_name}"></td>
                        <td th:text="${bean.arti_scort}"></td>
                        <td th:text="${bean.comments_size}"></td>
                        <td th:text="${bean.comments_people_size}"></td>
                        <td th:text="${bean.release_people}"></td>
                        <td>
                            <th:block th:if="${bean.is_recommended != 0}">否</th:block>
                            <th:block th:if="${bean.is_recommended == 0}">是</th:block>
                        </td>
                        <td>
                        <th:block th:if="${bean.is_comments == 0}">是</th:block>
                        <th:block th:if="${bean.is_comments != 0}">否</th:block>
                    </td>
                        <td th:text="${bean.creater}"></td>
                        <td th:text="${#dates.format(bean.cret_date, 'yyyy-MM-dd HH:mm:ss')}"></td>
                        <td th:text="${bean.modifier}"></td>
                        <td th:text="${#dates.format(bean.mod_date, 'yyyy-MM-dd HH:mm:ss')}"></td>

                        <td class="td-manage">
                            <th:block  th:each="funcion, funcionStat: ${funcions.obj.sonFuncion}">

                                <a th:if="${funcion.func_name == '更新'}"  th:href="${funcion.link_url + bean.id  + '&token='  + token}">更新  </a>
                                <a th:if="${funcion.func_name == '删除'}" href="###"  th:onclick="|updateValid(this,'确定要删除吗' ,${bean.id}, 1)|">删除  </a>
                                <a th:if="${funcion.func_name == '评论列表'}"  th:href="${funcion.link_url + bean.id  + '&token='  + token}">评论列表</a>
                            </th:block>
                        </td>
                    </tr>
                </th:block>
            </tbody>
        </table>
    </div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/static/v5/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/static/v5/js/kkpager.js"></script>
<script type="text/javascript" src="/static/v5/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/static/v5/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/static/v5/lib/layer/2.4/layer.js"></script>
<div th:if="${retInfo.mark == '0'}">
    <div style="margin: 0px 20px 0px 20px">
        <div id="kkpager"></div>
    </div>
    <script  th:inline="javascript">
        /*<![CDATA[*/
        var totalPage = [[${retInfo.obj.total_page}]];
        var totalRecords = [[${retInfo.obj.total_record}]];
        var pageNo = [[${retInfo.obj.current_page}]];
        var page_size = [[${retInfo.obj.page_size}]];
        var father_id = [[${father_id}]];
        var arti_name = [[${retInfo.obj.arti_name}]];
        var cate_id = [[${retInfo.obj.cate_id}]];
        /*]]>*/
        //init
        $(function() {

            if(!pageNo){
                pageNo = 1;
            }
            //生成分页
            //有些参数是可选的，比如lang，若不传有默认值
            kkpager.generPageHtml({
                pno : pageNo,
                //总页码
                total : totalPage,
                //总数据条数
                totalRecords : totalRecords,

                getLink : function(n){
                    var href = "/v5/admin/article/list" + "?page_size=" + page_size + "&father_id="+ father_id + "&current_page=" + n + "&token="  + sessionStorage.getItem("token")
                     "&cate_id=" + cate_id +    "&arti_name=" + arti_name
                    return href;
                }

            });
        });
        function  search() {
            var href = "/v5/admin/article/list" + "?page_size=" + page_size + "&father_id="+ father_id + "&current_page=" + 1 + "&token="  + sessionStorage.getItem("token")
           + "&cate_id=" + $("#cate_id").val() +    "&arti_name=" +  $("#arti_name").val()
            window.location.href = href;
        }
        function updateValid(bj,msg ,article_id, is_valid) {
            layer.confirm(msg ,function(index){
                var data = "article_id=" + article_id + "&is_valid=" + is_valid  + "&token="  + sessionStorage.getItem("token");
                $.ajax({
                    type:'post',
                    url:'/v5/admin/article/update/valid',
                    dataType : 'json',
                    data: data,
                    contentType: "application/x-www-form-urlencoded; charset=utf-8",
                    success:function(data){
                        if (data.mark=="0") {
                            window.location.reload();

                        } else {
                            alert(data.tip);
                        }
                    },
                    error: function(textStatus) {
                        alert(textStatus);
                    }

                });
            });

        }
    </script>
</div>

</body>
</html>
